import { Component ,Input,ElementRef,Renderer2,ViewChild} from '@angular/core';
import {  NavController, NavParams } from 'ionic-angular';
import { TopicInfo } from '../../models/quesinfo';
/**
 * Generated class for the QuestionCompletionPage page.
 *
 * See https://ionicframework.com/docs/components/#navigation for more info on
 * Ionic pages and navigation.
 */


@Component({
  selector: 'page-question-completion',
  templateUrl: 'question-completion.html',
})
export class QuestionCompletionPage {
  @Input() topic: TopicInfo;@Input() poneSet: Array<any>;
  @Input()
  topicIndex;
  topicIndexshow;
  title;
  @ViewChild('tk') tk: ElementRef;

  constructor(public navCtrl: NavController, public navParams: NavParams,private elementRef: ElementRef,public renderer2:Renderer2 ) {
    // let pEle = this.elementRef.nativeElement.querySelector('p');
    // pEle.innerHTML = this.topic.FTitle;

  }

  ionViewDidLoad() {
    //console.log('ionViewDidLoad QuestionCompletionPage');
  }

  ngOnInit(): void {
    // var subStr=new RegExp("<input type=\"text\" class=\"froalaText\" name=\"20006\" maxlength=\"50\" readonly=\"\">");
    // //console.log( subStr)



    let pEle = this.elementRef.nativeElement.querySelector('.completion');
    //Called after the constructor, initializing input properties, and the first call to ngOnChanges.
    //Add 'implements OnInit' to the class.
    this.topicIndexshow=this.topicIndex+1;
    pEle.innerHTML = this.topic.FTitle;
    let el = this.tk.nativeElement;


    // this.renderer2.removeAttribute(el.children[i], 'readonly');
    //
    for(var i = 0;i<el.children.length;i++){
      this.renderer2.removeAttribute(el.children[i], 'readonly');
    }

// //console.log(el.children)


    this.topic.completion = pEle;
    //
    // if(this.topic.strarr10003.length!=0){
    //
    //   for (var i = 0; i < this.topic.completion.children.length; i++) {
    //     this.topic.completion.children[i].value="asdsad";
    //   }
    // }


  }


}
